import React,{Component} from "react"
import { Space, Button } from 'antd'
import { DeleteOutlined, EditOutlined } from '@ant-design/icons';
class OperationButton extends Component{
    render(){
        const { record, actionType, modalVisible, editModal, handleView, deleteData,isView} = this.props
        return (
            <Space>
                {
                    isView ===true ?(
                        <>
                            <Button
                                size="small"
                                type='primary'
                                style={{ display: isView }}
                                ghost
                                onClick={e => {
                                    handleView(record, e)
                                    this.setState({
                                        actionType: actionType,
                                        modalVisible: modalVisible
                                    })
                                }}
                            >
                                查看详情
                            </Button>
                            <Button
                                size="small"
                                type='primary'
                                style={{ display: isView }}
                                icon={<DeleteOutlined />}
                                ghost
                                danger
                                onClick={e => {
                                    deleteData(record, e)
                                    this.setState({
                                        actionType: actionType,
                                        modalVisible: modalVisible
                                    })
                                }}
                            >
                                删除
                            </Button>
                        </>
                    ):(
                        <>
                                <Button
                                    size="small"
                                    type='primary'
                                    style={{ display: isView }}
                                    ghost
                                    onClick={e => {
                                        handleView(record, e)
                                        this.setState({
                                            actionType: actionType,
                                            modalVisible: modalVisible
                                        })
                                    }}
                                >
                                    查看详情
                                </Button>
                                <Button
                                    size="small"
                                    type='primary'
                                    style={{ display: isView }}
                                    icon={<EditOutlined />}
                                    ghost
                                    onClick={e => {
                                        editModal(record, e)
                                        this.setState({
                                            actionType: actionType,
                                            modalVisible: modalVisible
                                        })
                                    }}
                                >
                                    编辑
                                </Button>
                                <Button
                                    size="small"
                                    type='primary'
                                    style={{ display: isView }}
                                    icon={<DeleteOutlined />}
                                    ghost
                                    danger
                                    onClick={e => {
                                        deleteData(record, e)
                                        this.setState({
                                            actionType: actionType,
                                            modalVisible: modalVisible
                                        })
                                    }}
                                >
                                    删除
                                </Button>
                        </>
                    )
                }
            </Space>
        )
    }

}
export default OperationButton